﻿using Blazored.LocalStorage;
using Swimj.RazorLib.Caches;

namespace Client.BlazorWasmApp.Caches
{
    public class LocalSecureCache : ISecureCache
    {
        private readonly ILocalStorageService _localStorageService;

        public LocalSecureCache(ILocalStorageService localStorageService)
        {
            _localStorageService = localStorageService;
        }

        public async Task RemoveAsync(string key)
        {
            await _localStorageService.RemoveItemAsync(key);
        }

        public async Task<string> GetAsync(string key)
        {
            var value = await _localStorageService.GetItemAsStringAsync(key);

            return value;
        }

        public async Task SetAsync(string key, string? value)
        {
            await _localStorageService.SetItemAsStringAsync(key, value);
        }
    }
}